package com.siyu.basedata.zqrlb.controller;

import com.siyu.basedata.zqrlb.domain.ZqrlB;
import com.siyu.basedata.zqrlb.service.IZqrlBService;
import com.siyu.common.core.controller.BaseController;
import com.siyu.common.core.domain.AjaxResult;
import com.siyu.common.core.page.TableDataInfo;
import com.siyu.common.enums.BusinessType;
import com.siyu.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 水位退水曲线Controller
 *
 * @author hrhy
 * @date 2023-10-11
 */
@RestController
@RequestMapping("/basedata/zqrlb")
public class ZqrlBController extends BaseController {
    @Autowired
    private IZqrlBService zqrlBService;

    /**
     * 查询水位退水曲线列表
     */
    @PreAuthorize("@ss.hasPermi('gisdata:zqrlb:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZqrlB zqrlB) {
        startPage();
        List<ZqrlB> list = zqrlBService.selectZqrlBList(zqrlB);
        return getDataTable(list);
    }

    /**
     * 导出水位退水曲线列表
     */
    @PreAuthorize("@ss.hasPermi('gisdata:zqrlb:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZqrlB zqrlB) {
        List<ZqrlB> list = zqrlBService.selectZqrlBList(zqrlB);
        ExcelUtil<ZqrlB> util = new ExcelUtil<ZqrlB>(ZqrlB.class);
        util.exportExcel(response, list, "水位退水曲线数据");
    }

    /**
     * 获取水位退水曲线详细信息
     */
    @PreAuthorize("@ss.hasPermi('gisdata:zqrlb:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(zqrlBService.selectZqrlBById(id));
    }

    /**
     * 新增水位退水曲线
     */
    @PreAuthorize("@ss.hasPermi('gisdata:zqrlb:add')")
    @PostMapping
    public AjaxResult add(@RequestBody ZqrlB zqrlB) {
        return toAjax(zqrlBService.insertZqrlB(zqrlB));
    }

    /**
     * 修改水位退水曲线
     */
    @PreAuthorize("@ss.hasPermi('gisdata:zqrlb:edit')")
    @PutMapping
    public AjaxResult edit(@RequestBody ZqrlB zqrlB) {
        return toAjax(zqrlBService.updateZqrlB(zqrlB));
    }

    /**
     * 删除水位退水曲线
     */
    @PreAuthorize("@ss.hasPermi('gisdata:zqrlb:remove')")
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(zqrlBService.deleteZqrlBByIds(ids));
    }
}
